The present invention relates to processors for executing a Java Virtual Machine and, in particular, to a coprocessor that handles selected overhead portions of execution offloaded from a main processor.
The Java Virtual Machine is an abstract computing machine. The structure of this abstract computing machine, including its instruction set, have been defined by Sun Microsystems, Inc. and is set forth in xe2x80x9cThe Java Virtual Machine Specificationxe2x80x9d, published by Addison-Wesley in 1996. The Java Virtual Machine employs a xe2x80x9cclassxe2x80x9d file that contains Java Virtual Machine instructions (known as xe2x80x9cbytecodesxe2x80x9d). As envisioned by its creators, code written for the Java Virtual Machine is to be platform-independent. That is, code written for a Java Virtual Machine implemented for one underlying processor (or operating system) should execute identically when executed on a Java Virtual Machine implemented for another underlying processor (or operating system).
Many implementations of Java are interpreted, meaning that, in general, the Java bytecodes are fetched, decoded and executed in turn. Interpretation is slow mainly because of the additional level of decoding required. Furthermore, bytecodes interpretation is particularly slow because the Java Virtual Machine employs a stack machine model, which involves many slow pushes and pops from the machine stack. Programs written in Java, whether or not interpreted, are also known to execute relatively slowly because of the large amount of constraint checking that must be performed at runtime. Constraint checking is an important security consideration, since many Java programs are downloaded from insecure sources such as the internet.
To address the concerns of slowness, other implementations of Java perform just-in-time (xe2x80x9cJITxe2x80x9d) compilation of the Java bytecodes as described, for example, in xe2x80x9cCompiling Java Just in Timexe2x80x9d, in the May/June 1997 edition of IEEE Micro. Essentially, the compilation occurs at runtime, as opposed to more conventional compilation, which occurs before runtime. JIT is particularly beneficial when a portion of Java code (e.g., a Java method) will be executed more than once, and the overhead associated with its compilation can be substantially avoided for executions of the method after the first. Even the resulting JIT-compiled code, however, must include code for constraint checking.
Other factors affect the speed (or lack thereof) of execution of Java code. For example, xe2x80x9cgarbage collectionxe2x80x9d is an overhead task that executes to reclaim unused objects and, conventionally, takes processor cycles that could otherwise be used to execute Java instructions.
What is desired is a system that can competently implement the Java Virtual Machine Specification, in a way that provides improved speed of execution.
A coprocessor performs an overhead function of a Java virtual machine executing in a main processor. The coprocessor includes memory access circuitry configured to access a memory also accessible by the host processor. Pointer receiving circuitry is configured to receive at least one pointer to data in the memory pertinent to the overhead function. Function performing circuitry is configured to perform the overhead function to operate on the data in the memory pointed to by the at least one pointer. Result passing circuitry configured to pass a result back to the main processor. For example, overhead functions that may be performed by the coprocessor include bytecode verification, just-in-time compiling and garbage collection.